package gui;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import client.Client;
import client.Clientfunc;
import ocsf.client.*;
import client.*;
import java.awt.Dimension;

 

public class MainPanel extends JFrame {

	public Client client1;
	private JPanel login = null;
	private JLabel jLabelUserName = null;
	private JLabel jLabelPassword = null;
	private JLabel jLabelBackground = null;
	private JLabel jLabelWelcome = null;
	private JTextField jTextFieldUserName = null;
	private JPasswordField jPasswordFieldPassword = null;
	private JButton jButtonOK = null;
	private JLabel jLabelMassage = null;
	private MainCustomer MC;	
	private BufferedImage image;
	public MainPanel() {
		super();
		initialize();
	}

	/**
	 * This method initializes AcademicFrame 
	 */
	private void initialize() {
		this.setSize(1000, 718);
		this.setContentPane(getlogin());
		this.setTitle("Flower Shop");		
	}

	private JPanel getlogin() {
		if (login == null) {				
			ImageIcon imageBack = new ImageIcon("3.jpg"); 					
			ImageIcon welcome = new ImageIcon("welcome-logo-spring_1_.png");			
			jLabelBackground = new JLabel();
			jLabelBackground.setIcon(imageBack);
			jLabelBackground.setBounds(0, 0, 992, 690);
			jLabelWelcome = new JLabel();
			jLabelWelcome.setIcon(welcome);
			jLabelWelcome.setBounds(373, 14, 330, 330);
			jLabelMassage = new JLabel();
			jLabelMassage.setBounds(new Rectangle(315, 458, 404, 46));			
			jLabelPassword = new JLabel();
			jLabelPassword.setBounds(new Rectangle(374, 421, 96, 32));
			jLabelPassword.setText("PASSWORD");		
			jLabelUserName = new JLabel();
			jLabelUserName.setText("USERNAME");
			jLabelUserName.setBounds(new Rectangle(374, 360, 96, 32));
			login = new JPanel();
			login.setLayout(null);				
			login.add(jLabelUserName, null);
			login.add(jLabelPassword, null);
			login.add(getJTextFieldUserName(), null);
			login.add(getJPasswordFieldPassword(), null);
			login.add(getJButtonOK(), null);
			login.add(jLabelMassage, null);
			login.add(jLabelWelcome, null);
			login.add(jLabelBackground, null);
			
			
			

		}
		return login; 
	}

	/**
	 * This method initializes jTextFieldUserName	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldUserName() {
		if (jTextFieldUserName == null) {
			jTextFieldUserName = new JTextField();
			jTextFieldUserName.setBounds(new Rectangle(484, 362, 166, 29));
			
		}
		return jTextFieldUserName;
	}

	/**
	 * This method initializes jPasswordFieldPassword	
	 * 	
	 * @return javax.swing.JPasswordField	
	 */
	private JPasswordField getJPasswordFieldPassword() {
		if (jPasswordFieldPassword == null) {
			jPasswordFieldPassword = new JPasswordField();
			jPasswordFieldPassword.setBounds(new Rectangle(484, 422, 166, 29));
		}
		return jPasswordFieldPassword;
	}

	/**
	 * This method initializes jButtonOK	
	 * 	
	 * @return javax.swing.JButton	
	 */
	public JButton getJButtonOK() {
		if (jButtonOK == null) {
			jButtonOK = new JButton();
			jButtonOK.setBounds(new Rectangle(471, 511, 77, 46));
			jButtonOK.setText("OK");
			jButtonOK.setBackground(getBackground());
			jButtonOK.addActionListener(new java.awt.event.ActionListener() {
				@SuppressWarnings("deprecation")
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String[] array = new String[3];
							array[0] = "login";
							array[1] = jTextFieldUserName.getText();													
							array[2] = jPasswordFieldPassword.getText();
						//	Login log = new Login();
						//	log.setState(0);							
						//	Object answer= log.checkvalid(array[1], array[2], client1); 
							
							
						
					//client.Client.client.handleMessageFromServer(msg);							
					//String state =(String)msg;
				//			client.Client.
							
					
					
					/*
					if (state.equals("4"))
					{
					*/
						MainEmployee MFrame = new MainEmployee();
					    MFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
					    MFrame.setSize( 1000,720 ); // set frame size
					    MFrame.setResizable(true);
					    MFrame.setVisible( true ); // display frame
					    
					    Client.aFrame.dispose();	
					    /*
					}
					else
						System.out.println("error");
						*/	
					
				}
			});
		}
		return jButtonOK;
	}
	
}  //  @jve:decl-index=0:visual-constraint="12,11"
